package org.jeecg.modules.app.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.modules.app.entity.FoodCategory;
import org.jeecg.modules.app.entity.ShopCatalog;
import org.jeecg.modules.app.entity.Swipe;
import org.jeecg.modules.app.service.ShopCatalogService;
import org.jeecg.modules.app.service.SwipeService;
import org.jeecg.modules.app.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 李圳川
 * @version 1.0
 * @date 2022/6/15 1:55
 * @content
 */
@Api(tags="app首页数据")
@RestController
@RequestMapping("/schoolOrder/app/home")
public class HomeController {

    @Autowired
    private SwipeService swipeService;

    @Autowired
    private ShopCatalogService shopCatalogService;

    /**
     * 轮播图查询
     * @return
     */
    @ApiOperation("app轮播图查询")
    @GetMapping("/findSwipe")
    public Result<?> findSwipe(){
        List<Swipe> swipeList = swipeService.findSwipe();
        return Result.success("200","查询成功",swipeList);
    }

    /**
     * 商品分类查询
     * @return
     */
    @ApiOperation("app分类查询")
    @GetMapping("/findShopCatalog")
    public Result<?> findShopCatalog(@RequestParam(defaultValue = "1") Integer pageNum,
                                     @RequestParam(defaultValue = "10") Integer pageSize,
                                     @RequestParam(defaultValue = "") String search){

        Page<ShopCatalog> shopCatalogPage = shopCatalogService.findShopCatalog(pageNum,pageSize);
        return Result.success("200","查询成功",shopCatalogPage);
    }
}
